<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="http://g.alicdn.com/bui/bui/1.1.21/css/bs3/dpl.css" rel="stylesheet">
    <link href="http://g.alicdn.com/bui/bui/1.1.21/css/bs3/bui.css" rel="stylesheet">
    <link rel="stylesheet" href="<%=basePath%>static/bui-admin/index.css">
    <script src="http://g.tbcdn.cn/fi/bui/jquery-1.8.1.min.js"></script>
    <script src="http://g.alicdn.com/bui/bui/1.1.21/bui.js"></script>
</head>
<body>
<!-- Navigation -->
<div class="header">
    <div class="dl-title">
        <span class="lp-title-port">一元鸡</span><span class="dl-title-text">运营平台</span>
    </div>
    <div class="dl-log"><a href="<%=basePath%>rest/web/toLoginOut" title="退出系统" class="dl-log-quit">[退出]</a>
    </div>
</div>
<div class="content">
    <div class="dl-tab-item">
        <div class="dl-second-nav">
            <jsp:include page="menu.jsp" flush="true"/>
        </div>
        <div class="dl-inner-tab">
            <ol class="breadcrumb">
                <li>
                    <a href="">交易管理 </a>
                </li>
                <li class="active">/鸡蛋交易</li>
            </ol>
            <div class="row" style="margin: 0 10px">
                <form id="searchForm" class="form-panel">
                    <ul class="panel-content">
                        <li>
                            <div class="control-group span8">
                                <label class="control-label">状态：</label>
                                <div class="controls">
                                    <select name="status" class="input-normal" id="status">
                                        <option value="">全部</option>
                                        <option value="y">启用</option>
                                        <option value="n">禁用</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-actions span8">
                                <button   type="submit" class="button  button-primary"  >查询</button>
                            </div>
                        </li>

                    </ul>
                </form>
                <div id="grid"></div>
                <script>
                    var Grid = BUI.Grid,
                            Store = BUI.Data.Store,
                            columns = [
                                {title : '出售方',dataIndex :'sender', width:100},
                                {title : '购买方',dataIndex :'receive', width:200},
                                {title : '创建时间',dataIndex : 'createTime',width:300,renderer:function(data){
                                    var unixTimestamp = new Date( data ) ;
                                    return unixTimestamp.toLocaleString();
                                }},
                                {title : '交易数量',dataIndex : 'giftNum',width:200},
                                {title : '状态',dataIndex : 'status',width:100, renderer:function(data){
                                    if(data == "0"){
                                        return '等待付款';
                                    }
                                    if(data == "1"){
                                        return '交易完成';
                                    }
                                    if(data == "2"){
                                        return '等待收款';
                                    }
                                }
                                }
                            ];
                    var store = new Store({
                                url : '<%=basePath%>rest/web/eggData',
                                autoLoad:true, //自动加载数据
                                params : { //配置初始请求的参数
                                    length : '10',
                                    status:$("#status").val()
                                },
                                pageSize:10,    // 配置分页数目
                                root : 'data',
                                totalProperty : 'total'
                            }),
                            grid = new Grid.Grid({
                                render:'#grid',
                                columns : columns,
                                loadMask: true, //加载数据时显示屏蔽层
                                store: store,
                                plugins : [Grid.Plugins.CheckSelection], // 插件形式引入多选表格

                                // 底部工具栏
                                bbar:{
                                    pagingBar:true
                                }
                            });
                    grid.render();

                    var form = new BUI.Form.HForm({
                        srcNode : '#searchForm'
                    }).render();

                    form.on('beforesubmit',function(ev) {
                        //序列化成对象
                        var obj = form.serializeToObject();
                        obj.start = 0; //返回第一页
                        store.load(obj);
                        return false;
                    });

                </script>
            </div>
        </div>
    </div>
</div>
</body>
</html>
